cmake_minimum_required(VERSION 3.0.2)
project(ros_demo)

## 编译C++11
add_compile_options(-std=c++11)

## 查找依赖包
find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  geometry_msgs
  message_generation
)

## 生成消息和服务
add_message_files(
  FILES
  CustomMessage.msg
)

add_service_files(
  FILES
  AddTwoInts.srv
)

## 生成消息和服务
generate_messages(
  DEPENDENCIES
  std_msgs
  geometry_msgs
)

## catkin包配置
catkin_package(
  INCLUDE_DIRS include
  LIBRARIES ros_demo
  CATKIN_DEPENDS roscpp rospy std_msgs geometry_msgs message_runtime
  DEPENDS system_lib
)

## 包含目录
include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

## 可执行文件
add_executable(talker src/talker.cpp)
target_link_libraries(talker ${catkin_LIBRARIES})
add_dependencies(talker ros_demo_generate_messages_cpp)

add_executable(listener src/listener.cpp)
target_link_libraries(listener ${catkin_LIBRARIES})
add_dependencies(listener ros_demo_generate_messages_cpp)

add_executable(service_server src/service_server.cpp)
target_link_libraries(service_server ${catkin_LIBRARIES})
add_dependencies(service_server ros_demo_generate_messages_cpp)

add_executable(service_client src/service_client.cpp)
target_link_libraries(service_client ${catkin_LIBRARIES})
add_dependencies(service_client ros_demo_generate_messages_cpp)

## Python脚本
catkin_install_python(PROGRAMS
  scripts/talker.py
  scripts/listener.py
  scripts/service_server.py
  scripts/service_client.py
  DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
